﻿using System;
using System.ComponentModel.Composition;
using Caliburn.Micro;

namespace Scrabble.ViewModels
{
    [Export(typeof(SearchOptionsViewModel)), PartCreationPolicy(CreationPolicy.NonShared)]
    public class SearchOptionsViewModel : Screen
    {
        private bool _useTextAsPrefix = true;

        public event EventHandler SearchOptionsChanged;

        public bool UseTextAsPrefix
        {
            get { return _useTextAsPrefix; }
            set
            {
                if (value == UseTextAsPrefix) return;

                _useTextAsPrefix = value;
                NotifyOfPropertyChange(() => UseTextAsPrefix);
                NotifyOfPropertyChange(() => UseTextAsSetOfLetters);

                var handler = SearchOptionsChanged;
                if (handler != null) handler(this, EventArgs.Empty);
            }
        }

        public bool UseTextAsSetOfLetters
        {
            get { return ! UseTextAsPrefix; }
            set { UseTextAsPrefix = ! value; }
        }
    }
}
